import {
  BIND_INIT,
  BIND_CHANGE
} from '../actions';
import { updateState } from '../utils';

const INITIAL_STATE = {
  state: {
    time: 120,
    sendCodeStr : '发送验证码',
    isWaitting: false,
    timer: null
  },
  data: {
    mobile: '',
    veCode: ''
  },
  error: {
    hasError: false,
    msg: ''
  }
};

export default function (state = INITIAL_STATE, action = {}) {
  switch (action.type) {
    case BIND_INIT:
      {
        return { ...state, ...INITIAL_STATE }
      }
    case BIND_CHANGE:
      {
        return updateState(state, action.data);
      }
    default:
      return state;
  }
}